import logging

from fastapi import APIRouter, Depends

from like.schema_base import PageInationResult
from like.http_base import unified_resp
from .schemas import (
    MedicalDiseaseClassificationIcd20ListIn, MedicalDiseaseClassificationIcd20ExportIn, MedicalDiseaseClassificationIcd20DetailIn, MedicalDiseaseClassificationIcd20AddIn, 
    MedicalDiseaseClassificationIcd20EditIn, MedicalDiseaseClassificationIcd20DelIn, MedicalDiseaseClassificationIcd20Out)
from .service import IMedicalDiseaseClassificationIcd20Service, MedicalDiseaseClassificationIcd20Service

logger = logging.getLogger(__name__)

router = APIRouter(prefix='/ICD20')


@router.get('/list', response_model=PageInationResult[MedicalDiseaseClassificationIcd20Out])
@unified_resp
async def ICD20_list(
        list_in: MedicalDiseaseClassificationIcd20ListIn = Depends(),
        medical_disease_classification_icd20_service: IMedicalDiseaseClassificationIcd20Service = Depends(MedicalDiseaseClassificationIcd20Service.instance)):
    """存储疾病分类国际临床版 2.0 相关信息的列表"""
    result = await medical_disease_classification_icd20_service.list(list_in)
    return result

@router.get('/export', response_model=bytes)
@unified_resp
async def ICD20_export(export_in: MedicalDiseaseClassificationIcd20ExportIn = Depends(), MedicalDiseaseClassificationIcd20_service: IMedicalDiseaseClassificationIcd20Service = Depends(MedicalDiseaseClassificationIcd20Service.instance)):
    return await MedicalDiseaseClassificationIcd20_service.export_excel(export_in)


@router.get('/detail')
@unified_resp
async def ICD20_detail(
        detail_in: MedicalDiseaseClassificationIcd20DetailIn = Depends(),
        medical_disease_classification_icd20_service: IMedicalDiseaseClassificationIcd20Service = Depends(MedicalDiseaseClassificationIcd20Service.instance)):
    """存储疾病分类国际临床版 2.0 相关信息的详情"""
    return await medical_disease_classification_icd20_service.detail(detail_in.id)


@router.post('/add')
@unified_resp
async def ICD20_add(
        add_in: MedicalDiseaseClassificationIcd20AddIn,
        medical_disease_classification_icd20_service: IMedicalDiseaseClassificationIcd20Service = Depends(MedicalDiseaseClassificationIcd20Service.instance)):
    """存储疾病分类国际临床版 2.0 相关信息的新增"""
    return await medical_disease_classification_icd20_service.add(add_in)


@router.post('/edit')
@unified_resp
async def ICD20_edit(
        edit_in: MedicalDiseaseClassificationIcd20EditIn,
        medical_disease_classification_icd20_service: IMedicalDiseaseClassificationIcd20Service = Depends(MedicalDiseaseClassificationIcd20Service.instance)):
    """存储疾病分类国际临床版 2.0 相关信息的编辑"""
    return await medical_disease_classification_icd20_service.edit(edit_in)


@router.post('/del')
@unified_resp
async def ICD20_del(
        del_in: MedicalDiseaseClassificationIcd20DelIn,
        medical_disease_classification_icd20_service: IMedicalDiseaseClassificationIcd20Service = Depends(MedicalDiseaseClassificationIcd20Service.instance)):
    """存储疾病分类国际临床版 2.0 相关信息的删除"""
    return await medical_disease_classification_icd20_service.delete(del_in.id)
